var app = getApp(), u = app.require("utils/util.js"), a = app.require("utils/api.js"), o = app.require("utils/onfire.js"), h = app.require("utils/http.js"), n = app.require("utils/enums");

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: null,
    tabName:[
      { id: 1, type:'unpay', name: '待付款', image: '/packages/images/tab-obligation@2x.png', fun: 'toMyOrder'},
      { id: 2, type:'unsend',name: '待发货', image: '/packages/images/tab-shipments@2x.png', fun: 'toMyOrder'},
      { id: 3, type:'send',name: '待收货', image: '/packages/images/tab-delivery@2x.png' ,fun:'toMyOrder'},
      { id: 4, type:'complete',name: '评价', image: '/packages/images/tab-evaluate@2x.png', fun:'goEvaluate' }
    ],
    tabServiceName:[
      { id: 5, name: '购物车', image: '/packages/images/tab-cart@2x.png', fun:'goCart'},
      { id: 6, name: '优惠券', image: '/packages/images/tab-coupon@2x.png', fun:'goCoupon'},
      { id: 7, name: '我的收藏', image: '/packages/images/tab-collect@2x.png', fun:'goCollect'},
      { id: 8, name: '收货地址', image: '/packages/images/tab-address@2x.png', fun:'goAddress'}
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var t = this;
    app.getToken();
    t.data.userInfo = wx.getStorageSync('userInfo') ? wx.getStorageSync('userInfo') : app.callAuthorize(function (userInfo) { t.data.userInfo = userInfo}),
    t.setData({ userInfo: t.data.userInfo });
  },
  // 我的订单
  toMyOrder:function(e){
    var type = e.currentTarget.dataset.type ? e.currentTarget.dataset.type : '';
    wx.navigateTo({
      url: '../../order/my/index?type='+type,
    })
  },
  // 评价管理
  goEvaluate:function(){
    wx.navigateTo({
      url: '../evaluate/evaluate',
    })
  },
  // 购物车
  goCart:function(){
    wx.switchTab({
      url: '/pages/cart/index/index',
    })
  },
  // 优惠券
  goCoupon:function(){
    wx.navigateTo({
      url: '../coupon/coupon',
    })
  },
  // 我的收藏
  goCollect:function(){
    wx.navigateTo({
      url: '../collect/collect',
    })
  },
  // 收货地址
  goAddress:function(){
    wx.navigateTo({
      url: '../address/index',
    })
  }
})